#include "PCF8574.h"

void PCF8574Init()
{
      	i2c_init();		//CV
      	
      	i2c_start();
      	
      	i2c_write( 0b01000000 );
      	i2c_write( 0b11111111 );
       	i2c_stop();
}

void PCF8574Write( const char data )
{ 
	i2c_start();
      	i2c_write( 0b01000000 );
      	i2c_write( data );
       	i2c_stop();     
}

char PCF8574read()
{        
	char data;
	i2c_start();
      	i2c_write( 0b01000000 );
      	i2c_write( 0xff );
	i2c_stop();
	i2c_start();
      	i2c_write( 0b01000001 );
      
      
      	data = i2c_read( 0 );
       	i2c_stop();       
       	return( data );
}	